home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / AEglobalCacheControlTemplate < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.9 KB  |  291 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Creation Date:    May 23, 1997
  19. //  Author:        sw
  20. //
  21. //  Procedure Name:
  22. //    AEglobalCacheControlTemplate
  23. //
  24. //  Description Name;
  25. //    Creates the attribute editor controls for the globalCacheControl Node
  26. //
  27. //  Input Value:
  28. //    nodeName 
  29. //
  30. //  Output Value:
  31. //    None
  32. // 
  33.  
  34. global proc AEcacheControlReplace()
  35. {
  36.     string $currentMenu = `optionMenuGrp -q -v cacheMenu`;
  37.  
  38.     int $totalMenuItems = `optionMenuGrp -q -numberOfItems cacheMenu`;
  39.  
  40.     string $allItemNames[] = `optionMenuGrp -q -ils cacheMenu`;
  41.  
  42.     string $nodes[] = `ls -type "diskCache"`;
  43.     optionMenuGrp -e cacheMenu;
  44.  
  45.     int $nth;
  46.     int $n = 0;
  47.     string $mcj = "mcj";
  48.     string $mcjNodes[];
  49.     for( $nth = 1; $nth <= size($nodes); $nth++) {
  50.         string $cacheType = `getAttr ($nodes[$nth-1] + ".cacheType")`;
  51.         if( $cacheType == $mcj ) {
  52.             $mcjNodes[$n] = $nodes[$nth-1];
  53.             $n++;
  54.         } 
  55.     }
  56.  
  57.     // If no disk cache exists
  58.     if( size($mcjNodes) == 0 ) {
  59.         // leave one menuItem and delte the rest
  60.         // Set the first menu item to "No Disk Cache"
  61.         menuItem -e -l "No Disk Cache" $allItemNames[0];
  62.         $n = 1;
  63.     } else {
  64.         $n = size($mcjNodes);
  65.     }
  66.  
  67.     // Delete the rest
  68.     for( $nth = $n+1; $nth <= $totalMenuItems; $nth++ ) {
  69.         string $itemName = $allItemNames[$nth-1];
  70.         deleteUI $itemName;        
  71.     }
  72.     if( size($mcjNodes) == 0 ) return;
  73.  
  74.     if( $totalMenuItems > $n ) $totalMenuItems = $n;
  75.  
  76.     // Build menu items for each disk cache
  77.     int $currentNth = 1;
  78.     for( $nth = 1; $nth <= $totalMenuItems; $nth++ ) {
  79.         string $tmpName = `getAttr ($mcjNodes[$nth-1] + ".cacheName")`;
  80.         if( size($tmpName) == 0 ) 
  81.             $tmpName = `getAttr ($mcjNodes[$nth-1] + ".hiddenCacheName")`;
  82.         if( $tmpName == $currentMenu ) $currentNth = $nth;
  83.         optionMenuGrp -e -sl $nth cacheMenu;
  84.         menuItem -e -l $tmpName $allItemNames[$nth - 1];
  85.     }
  86.     // This is a fix to get around the optionMenuGrp bug (#81337)
  87.     string $fullName = `setParent "cacheMenu"`;
  88.     string $menuName = ($fullName+"|OptionMenu");
  89.     setParent -m $menuName;
  90.     for( $nth = $totalMenuItems + 1; $nth <= size($mcjNodes); $nth++ ) {
  91.         string $tmpName = `getAttr ($mcjNodes[$nth-1] + ".cacheName")`;
  92.         if( size($tmpName) == 0 ) 
  93.             $tmpName = `getAttr ($mcjNodes[$nth-1] + ".hiddenCacheName")`;
  94.         if( $tmpName == $currentMenu ) $currentNth = $nth;
  95.         menuItem -l $tmpName;
  96.     }
  97.  
  98.     // Set the current menuItem
  99.     optionMenuGrp -e -sl $currentNth cacheMenu;
  100.     if( size($mcjNodes) >= 0 ) {
  101.         string $selectedCache = $mcjNodes[$currentNth-1];
  102.         connectControl -index 2 startTime ($selectedCache+".startTime");
  103.         connectControl -index 2 endTime ($selectedCache+".endTime");
  104.         connectControl -index 2 samplingRate ($selectedCache+".samplingRate");
  105.         connectControl -index 2 samplingType ($selectedCache+".samplingType");
  106.     } else {
  107.         menuItem -l "No Disk Cache";
  108.         floatFieldGrp -e -value1 0 startTime;
  109.         floatFieldGrp -e -value1 0 endTime;
  110.         optionMenuGrp -e -sl $currentNth samplingType;
  111.         menuItem -l "Over Sample";
  112.         intFieldGrp   -e -value1 0 samplingRate;
  113.     }
  114.  
  115.     setParent ..;
  116. }
  117.  
  118. global proc AEcacheControlNew()
  119. {
  120.     setUITemplate -pushTemplate attributeEditorTemplate;
  121.         optionMenuGrp -label "Cache Name" cacheMenu;
  122.                 menuItem -l "No Disk Cache";
  123.     setUITemplate -popTemplate;
  124.  
  125.     setUITemplate -pushTemplate attributeEditorTemplate;
  126.         floatFieldGrp -nf 1 -en1 false -label "Start Time" startTime;
  127.         floatFieldGrp -nf 1 -en1 false -label "End Time" endTime;
  128.         optionMenuGrp -en false -label "Sampling Type" samplingType;
  129.             menuItem -label "Over Sample";
  130.             menuItem -label "Under Sample";
  131.         intFieldGrp -nf 1 -en1 false -label "Sampling Rate" samplingRate;
  132.     setUITemplate -popTemplate;
  133.  
  134.     AEcacheControlReplace;
  135. }
  136.  
  137. global proc AEdeleteAllCache()
  138. {
  139.     string $caches[] = `ls -type "diskCache"`;
  140.     for( $c in $caches ) {
  141.         // Only delete all *jiggle* caches...
  142.         //
  143.         if( `getAttr ($c + ".cacheType")` == "mcj" ) {
  144.             diskCache -delete $c;
  145.         }
  146.     }
  147.  
  148.     AEcacheControlReplace;
  149. }
  150.  
  151. global proc AEdeleteAllCacheNew()
  152. {
  153.     setUITemplate -pst attributeEditorTemplate;
  154.     rowLayout -nc 2;
  155.         text -l " ";
  156.         button -label "Delete All Caches" 
  157.                -c ("evalEcho AEdeleteAllCache") 
  158.                -width 80 deleteAllCache;
  159.         setParent ..;
  160.     setUITemplate -ppt;
  161. }
  162.  
  163. global proc AEdeleteAllCacheReplace()
  164. {
  165.  
  166. }
  167.  
  168. global proc AEglobalCacheEnableNew()
  169. //
  170. // Description:
  171. //    Create the option menu for enabling/disabling all 
  172. //    jiggle caches.
  173. //
  174. {
  175.     setUITemplate -pst attributeEditorTemplate;
  176.  
  177.     optionMenuGrp -l "Enable Status" 
  178.         -cc AEglobalCacheEnableChanged
  179.         globalCacheEnable;
  180.  
  181.         menuItem -l "Enable All";
  182.         menuItem -l "Disable All";
  183.         setParent ..;
  184.  
  185.     setUITemplate -ppt attributeEditorTemplate;
  186.  
  187.     AEglobalCacheEnableReplace();
  188. }
  189.  
  190. global proc AEglobalCacheEnableReplace()
  191. //
  192. // Description:
  193. //    We have to "connect" the option menu so that it displays
  194. //    the right value : are all jiggle caches enabled or disabled?
  195. //    
  196. {
  197.     int $onCount  = 0;
  198.     int $offCount = 0;
  199.     int $jiggleCount = 0;
  200.  
  201.     string $caches[] = `ls -type diskCache`;
  202.     for( $c in $caches ) {
  203.         if( `getAttr ($c + ".cacheType" )` != "mcj" ) {
  204.             continue;
  205.         }
  206.  
  207.         $jiggleCount++;
  208.  
  209.         if( `getAttr ( $c + ".enable" )` ) {
  210.             $onCount++;
  211.         } else {
  212.             $offCount++;
  213.         }
  214.     }
  215.  
  216.     // Select the All Enabled item
  217.     //
  218.     if( $onCount == $jiggleCount ) {
  219.         optionMenuGrp -e -v "Enable All" globalCacheEnable;
  220.     } 
  221.     // Select the All Disbled item
  222.     //
  223.     else if( $offCount == $jiggleCount ) {
  224.         optionMenuGrp -e -v "Disable All" globalCacheEnable;
  225.     } 
  226.     // Cache status is mixed.  If we're showing
  227.     // UI that indicates they're all on or all off,
  228.     // we'd better set them that way...
  229.     // 
  230.     // Note that there's no UI to turn an individual
  231.     // diskCache node on or off, so this actually
  232.     // shouldn't really even happen...
  233.     //
  234.     else {
  235.         AEglobalCacheEnableChanged();
  236.     }
  237. }
  238.  
  239. proc AEglobalCacheSetAllJiggle( int $enable )
  240. //
  241. // Description:
  242. //    Helper proc to set the enabled state of all jiggle caches.
  243. //    
  244. {
  245.     string $caches[] = `ls -type diskCache`;
  246.     for( $c in $caches ) {
  247.         if( `getAttr ($c + ".cacheType" )` != "mcj" ) {
  248.             continue;
  249.         }
  250.  
  251.         setAttr ( $c + ".enable" ) $enable;
  252.     }
  253. }
  254.  
  255. global proc AEglobalCacheEnableChanged()
  256. //
  257. // Description:
  258. //    Take the current value of the option menu and apply it
  259. //    to all jiggle caches in the scene.
  260. //
  261. {
  262.     string $status = `optionMenuGrp -q -value globalCacheEnable`;
  263.     if( $status == "Enable All" ) {
  264.         AEglobalCacheSetAllJiggle( true );
  265.     } else if( $status == "Disable All" ) {
  266.         AEglobalCacheSetAllJiggle( false );
  267.     }
  268. }
  269.  
  270. global proc AEglobalCacheControlTemplate ( string $nodeName )
  271. {
  272.     editorTemplate -beginLayout "Control For All Caches" -collapse false;
  273.         editorTemplate -suppress enableStatus;
  274.         editorTemplate -callCustom "AEglobalCacheEnableNew" "AEglobalCacheEnableReplace";
  275.  
  276.            editorTemplate -callCustom "AEdeleteAllCacheNew" "AEdeleteAllCacheReplace";
  277.     editorTemplate -endLayout;
  278.  
  279.     editorTemplate -beginLayout "Individual Cache Status" -collapse false;
  280.         editorTemplate -callCustom "AEcacheControlNew"
  281.             "AEcacheControlReplace" ;
  282.     editorTemplate -endLayout;
  283.  
  284.     editorTemplate -suppress writeEnable;
  285.  
  286.     AEdependNodeTemplate $nodeName;
  287.  
  288.     editorTemplate -addExtraControls;
  289.  
  290. }
  291.